/**
 * kig
 * 2006
 */

#include "Util.h"

#ifndef KIG_IMAGE_H
#define KIG_IMAGE_H

namespace kig
{
	/**
	 * Drop of paint on a Canvas...
	 * Each Drop can be composed of multiple samples.
	 * TODO : Do I want this reference counted?
	 */
	class Drop
	{
		public:
			/** Add a sample to the Drop. */
			void add(Vec4 s) { samples.push_back(s); }
			std::vector<Vec4> samples;
	};

	/**
	 * The final image is stored on a Canvas.
	 */
	class Canvas : public Object 
	{
		public:
			/**
			 * Constructor.
			 * @param w width of Canvas
			 * @param h height of Canvas
			 */
			Canvas(unsigned int w, unsigned int h);

			/**
			 * Return the width of the Canvas.
			 */
			unsigned int getWidth() const { return _width; } 

			/**
			 * Return the height of the Canvas.
			 */
			unsigned int getHeight() const { return _height; }
			
			/**
			 * Return a pointer to the Drop at (x,y).
			 * Bounds checking with DEBUG.
			 * @param x col 
			 * @param y row
			 */
			Drop* operator()(unsigned int x, unsigned int y);

			/**
			 * Dump the contents of the canvas into PPM format.
			 */
			void dumpToPPM(std::ostream& ppm); //, bool ascii=1);

			/**
			 * Return a description of the Canvas.
			 */
			std::string getDesc() const;
			
			/**
			 * Destructor.
			 */
			~Canvas();

		private:
			/**
			 * The width of the Canvas.
			 */
			unsigned int _width;

			/**
			 * The height of the Canvas.
			 */
			unsigned int _height;
			
			/**
			 * The drops of paint on the Canvas.
			 */
			Drop* _drops;
	};

	REF_POINTER(Canvas, CanvasPtr);
}

#endif
